﻿package 
{

	import flash.display.MovieClip;
	import flash.events.Event;

	public class BigLockBlock extends Obstacle
	{

		private var unlocked:Boolean = false;
		var _player:Player;


		public function BigLockBlock(aX:Number,aY:Number,aWidth:Number,aHeight:Number,aPlayer:Player)
		{
			// constructor code
			super(aX,aY,aWidth,aHeight);

			_player = aPlayer;
			this.addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
			
		}
		
		private function onAddedToStage(e:Event){
			if(!unlocked)
			{
				gotoAndStop(0);
			}
			else
			{
				gotoAndStop(2);
			}
		}

		override public function CollisionCheck(locX:int, locY:int):Boolean
		{
			//trace("" + hitTestPoint(locX,locY));

			if (hitTestPoint(locX,locY))
			{
				if (_player.BigKey == true && ! unlocked)
				{
					unlocked = true;
					this.nextFrame();
					_player.BigKey = false;
				}
			}

			if (! unlocked)
			{
				return hitTestPoint(locX,locY);
			}
			else
			{
				return false;
			}


		}

	}
}